﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MyWeb.Common;
using MyWeb.Data;
using MyWeb.Business;


namespace MyWeb.Admins
{
    public partial class Login1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnLogon_Click(object sender, EventArgs e)
        {
            

            //var dt = UserService.User_CheckLogin(txtUsername.Text, txtPassword.Text);
            var dt = tblAdminService.tblAdmin_GetByTop("", "_aname='" + txtUsername.Text + "' AND _apassword='" + txtPassword.Text + "'", "");
            if (dt.Rows.Count > 0)
            {
                int qh;
                qh = Convert.ToInt32(dt.Rows[0]["_arole"].ToString());
                if (qh < 3 && qh > 0)
                {
                    Session["Role"] = qh;
                    Session["Username"] = txtUsername.Text.Trim();
                    Response.Redirect("~/Admin/Default.aspx");
                }
                else
                {
                    WebMsgBox.Show("Error!");
                }
            }
        }

        protected void btnHuyBo_Click(object sender, EventArgs e)
        {

        }
    }
}